//call和apply的区别：传递的参数不同,call的参数是若干个参数列表，apply的参数是数组
//bind的区别：最后会返回一个函数

Function.prototype.MyCall = function (context) {
  let obj = context || window
  obj.fn = this
  const args = [...arguments].slice(1)
  const result = obj.fn(...args)
  delete obj.fn
  return result
}

Function.prototype.MyApply = function (context) {
  let obj = context || window
  obj.fn = this
  const args = [...arguments][1]
  const result = obj.fn(...args)
  delete obj.fn
  return result
}

Function.prototype.MyBind = function (context) {
  let self = this
  const args = [...arguments].slice(1)
  return function () {
    return self.apply(context, args.concat(...arguments))
  }
}
